home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Menu Repla185894202001.psc / Example.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-04-20  |  11.0 KB  |  328 lines

  1. VERSION 5.00
  2. Object = "{D9FDB204-2D4F-4C34-864A-9D9289DB746F}#59.0#0"; "Menu.ocx"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Custom Menu Example 2"
  5.    ClientHeight    =   2715
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   4020
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   2715
  11.    ScaleWidth      =   4020
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Frame Frame2 
  14.       Caption         =   "Enabled"
  15.       Height          =   1815
  16.       Left            =   2160
  17.       TabIndex        =   5
  18.       Top             =   840
  19.       Width           =   1815
  20.       Begin VB.CheckBox Check9 
  21.          Caption         =   "Use Left Image"
  22.          Height          =   195
  23.          Left            =   120
  24.          TabIndex        =   15
  25.          Top             =   1200
  26.          Value           =   1  'Checked
  27.          Width           =   1455
  28.       End
  29.       Begin VB.CheckBox Check8 
  30.          Caption         =   "Animate"
  31.          Height          =   255
  32.          Left            =   120
  33.          TabIndex        =   14
  34.          Top             =   1440
  35.          Value           =   1  'Checked
  36.          Width           =   975
  37.       End
  38.       Begin VB.CheckBox Check7 
  39.          Caption         =   "Paste"
  40.          Height          =   255
  41.          Left            =   960
  42.          TabIndex        =   13
  43.          Top             =   480
  44.          Width           =   735
  45.       End
  46.       Begin VB.CheckBox Check6 
  47.          Caption         =   "Copy"
  48.          Height          =   255
  49.          Left            =   960
  50.          TabIndex        =   12
  51.          Top             =   240
  52.          Value           =   1  'Checked
  53.          Width           =   735
  54.       End
  55.       Begin VB.CheckBox Check5 
  56.          Caption         =   "Cut"
  57.          Height          =   255
  58.          Left            =   120
  59.          TabIndex        =   11
  60.          Top             =   960
  61.          Value           =   1  'Checked
  62.          Width           =   855
  63.       End
  64.       Begin VB.CheckBox Check4 
  65.          Caption         =   "Exit"
  66.          Height          =   255
  67.          Left            =   960
  68.          TabIndex        =   9
  69.          Top             =   720
  70.          Value           =   1  'Checked
  71.          Width           =   615
  72.       End
  73.       Begin VB.CheckBox Check3 
  74.          Caption         =   "Delete"
  75.          Height          =   255
  76.          Left            =   120
  77.          TabIndex        =   8
  78.          Top             =   720
  79.          Value           =   1  'Checked
  80.          Width           =   855
  81.       End
  82.       Begin VB.CheckBox Check2 
  83.          Caption         =   "Save"
  84.          Height          =   255
  85.          Left            =   120
  86.          TabIndex        =   7
  87.          Top             =   480
  88.          Width           =   735
  89.       End
  90.       Begin VB.CheckBox Check1 
  91.          Caption         =   "New"
  92.          Height          =   255
  93.          Left            =   120
  94.          TabIndex        =   6
  95.          Top             =   240
  96.          Value           =   1  'Checked
  97.          Width           =   735
  98.       End
  99.    End
  100.    Begin VB.Frame Frame1 
  101.       Caption         =   "Border && Selection Style"
  102.       Height          =   1695
  103.       Left            =   120
  104.       TabIndex        =   3
  105.       Top             =   840
  106.       Width           =   1935
  107.       Begin VB.ListBox List2 
  108.          Height          =   645
  109.          ItemData        =   "Example.frx":0000
  110.          Left            =   120
  111.          List            =   "Example.frx":000D
  112.          TabIndex        =   16
  113.          Top             =   960
  114.          Width           =   1695
  115.       End
  116.       Begin VB.ListBox List1 
  117.          Height          =   645
  118.          ItemData        =   "Example.frx":0034
  119.          Left            =   120
  120.          List            =   "Example.frx":0041
  121.          TabIndex        =   4
  122.          Top             =   240
  123.          Width           =   1695
  124.       End
  125.    End
  126.    Begin Menu_Replacement.MenuCtl Menu1 
  127.       Left            =   0
  128.       Top             =   1200
  129.       _ExtentX        =   847
  130.       _ExtentY        =   847
  131.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  132.          Name            =   "Arial"
  133.          Size            =   9.75
  134.          Charset         =   0
  135.          Weight          =   700
  136.          Underline       =   0   'False
  137.          Italic          =   0   'False
  138.          Strikethrough   =   0   'False
  139.       EndProperty
  140.       ItemHotForeColor=   255
  141.       BackColor       =   10454404
  142.       ItemHotBackColor=   16761024
  143.       OpenAnimated    =   -1  'True
  144.       UseLeftImage    =   -1  'True
  145.       LeftPicBackColor=   0
  146.       MouseOverSelectionType=   1
  147.    End
  148.    Begin VB.CommandButton Command3 
  149.       Caption         =   "Click + Icons"
  150.       Height          =   615
  151.       Left            =   2760
  152.       TabIndex        =   2
  153.       Top             =   120
  154.       Width           =   1215
  155.    End
  156.    Begin VB.CommandButton Command2 
  157.       Caption         =   "Mouse Down"
  158.       Height          =   615
  159.       Left            =   1440
  160.       TabIndex        =   1
  161.       Top             =   120
  162.       Width           =   1215
  163.    End
  164.    Begin VB.CommandButton Command1 
  165.       Caption         =   "Click"
  166.       Height          =   615
  167.       Left            =   120
  168.       TabIndex        =   0
  169.       Top             =   120
  170.       Width           =   1215
  171.    End
  172.    Begin VB.Image Image7 
  173.       Height          =   1500
  174.       Left            =   1920
  175.       Picture         =   "Example.frx":0060
  176.       Top             =   840
  177.       Visible         =   0   'False
  178.       Width           =   240
  179.    End
  180.    Begin VB.Image Image6 
  181.       Height          =   240
  182.       Left            =   0
  183.       Picture         =   "Example.frx":1362
  184.       Top             =   2160
  185.       Visible         =   0   'False
  186.       Width           =   240
  187.    End
  188.    Begin VB.Image Image5 
  189.       Height          =   240
  190.       Left            =   0
  191.       Picture         =   "Example.frx":16EC
  192.       Top             =   1920
  193.       Visible         =   0   'False
  194.       Width           =   240
  195.    End
  196.    Begin VB.Image Image4 
  197.       Height          =   240
  198.       Left            =   0
  199.       Picture         =   "Example.frx":1A76
  200.       Top             =   1680
  201.       Visible         =   0   'False
  202.       Width           =   240
  203.    End
  204.    Begin VB.Label Label1 
  205.       Caption         =   "By Daniel Taylor..."
  206.       Height          =   255
  207.       Left            =   120
  208.       TabIndex        =   10
  209.       Top             =   2520
  210.       Width           =   1935
  211.    End
  212.    Begin VB.Image Image3 
  213.       Height          =   240
  214.       Left            =   0
  215.       Picture         =   "Example.frx":1E00
  216.       Top             =   840
  217.       Visible         =   0   'False
  218.       Width           =   240
  219.    End
  220.    Begin VB.Image Image2 
  221.       Height          =   240
  222.       Left            =   0
  223.       Picture         =   "Example.frx":218A
  224.       Top             =   600
  225.       Visible         =   0   'False
  226.       Width           =   240
  227.    End
  228.    Begin VB.Image Image1 
  229.       Height          =   240
  230.       Left            =   0
  231.       Picture         =   "Example.frx":2514
  232.       Top             =   360
  233.       Visible         =   0   'False
  234.       Width           =   240
  235.    End
  236. Attribute VB_Name = "Form1"
  237. Attribute VB_GlobalNameSpace = False
  238. Attribute VB_Creatable = False
  239. Attribute VB_PredeclaredId = True
  240. Attribute VB_Exposed = False
  241. 'Example for Menu.ocx Windows Menu Replacement Control
  242. 'Created By Daniel Taylor on 17 April 2001
  243. 'This code just demonstrates the use of my Menu.ocx file.
  244. 'it shows how to make a menu, have it show, and get the
  245. 'results when its clicked on and respond to these results.
  246. 'It just shows off a little of what you can do with the menu
  247. 'Also, the colors are all changable, try experimenting, and
  248. 'As always if you like the code, VOTE!!!!(Font is changeable, too)
  249. '::::::To use it:::::
  250. 'first make a menu using the
  251. '.AddItem ItemText, [ItemName], [Enabled], [Icon], [Forecolor], [HotForecolor], [HotBackcolor]
  252. 'then once all done, just show the menu using
  253. '.ShowMenu [X], [Y]
  254. 'If X & Y are not specified, it opens where the cursor is at
  255. 'When the mouse is let up the menu closes and gives back the
  256. 'Index and Text of the Item clicked, and then i set it up
  257. 'to either display certain messages or to exit the program.
  258. 'Also, I used a few image controls instead of an imagelist,
  259. 'but i think it would be easier to use the imagelist for the icons...
  260. Private Sub Check8_Click()
  261.     'tell the menu to open animated if check8 is checked,
  262.     'else, don't animate
  263.     Menu1.OpenAnimated = Check8
  264. End Sub
  265. Private Sub Check9_Click()
  266.     Menu1.UseLeftImage = Check9
  267. End Sub
  268. Private Sub Command1_Click()
  269.     'create normal menu, no icons
  270.     Menu1.AddItem "New...", , Check1, , RGB(100, 100, 0)
  271.     Menu1.AddItem "Save...", , Check2
  272.     Menu1.AddItem "Delete...", , Check3, , , RGB(150, 0, 150)
  273.     Menu1.AddItem "", "Seperator"
  274.     Menu1.AddItem "Cut", , Check5, , , , RGB(0, 255, 0)
  275.     Menu1.AddItem "Copy", , Check6, , RGB(0, 100, 100)
  276.     Menu1.AddItem "Paste", , Check7
  277.     Menu1.AddItem "", "seperator"
  278.     Menu1.AddItem "Exit", , Check4
  279.     'show the menu
  280.     Menu1.ShowMenu , , Image7.Picture
  281. End Sub
  282. Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  283.     'just make and show the menu again
  284.     Call Command1_Click
  285. End Sub
  286. Private Sub Command3_click()
  287.     'this time build it with icons...
  288.     'set the icon usage to true
  289.     'don't specify an icon, and the space next to the text
  290.     'is blank, just like the windows menus... (i.e. the exit item)
  291.     Menu1.UseIcons = True
  292.     Menu1.AddItem "New...", , Check1, Image1.Picture, RGB(100, 100, 0)
  293.     Menu1.AddItem "Save...", , Check2, Image2.Picture
  294.     Menu1.AddItem "Delete...", , Check3, Image3.Picture, , RGB(150, 0, 150)
  295.     Menu1.AddItem "", "Seperator"
  296.     Menu1.AddItem "Cut", , Check5, Image4.Picture, , , RGB(0, 255, 0)
  297.     Menu1.AddItem "Copy", , Check6, Image5.Picture, RGB(0, 100, 100)
  298.     Menu1.AddItem "Paste", , Check7, Image6.Picture
  299.     Menu1.AddItem "", "seperator"
  300.     Menu1.AddItem "Exit", , Check4
  301.     'once again show the menu
  302.     Menu1.ShowMenu , , Image7.Picture
  303.     'make sure to reset the icon usage
  304.     Menu1.UseIcons = False
  305. End Sub
  306. Private Sub Form_Load()
  307.     List1.ListIndex = 0
  308.     List2.ListIndex = 1
  309. End Sub
  310. Private Sub List1_Click()
  311.     'change the borderstyle of the menu
  312.     Menu1.Style = List1.ListIndex
  313. End Sub
  314. Private Sub List2_Click()
  315.     Menu1.MouseOverSelectionType = List2.ListIndex
  316. End Sub
  317. Private Sub Menu1_ItemClicked(Index As Integer, Text As String, Name As String)
  318.     'get results of menu when it closes, then process the text
  319.     If Text = "Exit" Then
  320.         DoEvents
  321.         Unload Me
  322.     ElseIf Text = "New..." Then
  323.         MsgBox "New Not Possible..."
  324.     Else
  325.         MsgBox "You clicked an item with the index of " & Index & " and the text: " & Text
  326.     End If
  327. End Sub
  328.